package com.kingdee.eas.hr.emp.client;

import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.swing.JButton;
import javax.swing.KeyStroke;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;

import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTableHelper;
import com.kingdee.bos.ctrl.kdf.table.event.KDTDataFillListener;
import com.kingdee.bos.ctrl.kdf.table.event.KDTDataRequestEvent;
import com.kingdee.bos.ctrl.kdf.table.event.KDTMouseEvent;
import com.kingdee.bos.ctrl.swing.tree.DefaultKingdeeTreeNode;
import com.kingdee.bos.ctrl.swing.util.CtrlSwingUtilities;
import com.kingdee.bos.metadata.MetaDataPK;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.base.commonquery.client.CommonQueryDialog;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.basedata.org.OrgF7InnerUtils;
import com.kingdee.eas.basedata.org.PositionInfo;
import com.kingdee.eas.basedata.org.client.tree.NewOrgTreeHelper;
import com.kingdee.eas.basedata.person.Genders;
import com.kingdee.eas.basedata.person.PersonCollection;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.custom.hr.affair.probation.EvaluationResultEnum;
import com.kingdee.eas.framework.ICoreBase;
import com.kingdee.eas.hr.affair.AffairUpgradeFacadeFactory;
import com.kingdee.eas.hr.base.BaseInnerFacadeFactory;
import com.kingdee.eas.hr.base.EmployeeFenLeiInfo;
import com.kingdee.eas.hr.base.EmployeeTypeInfo;
import com.kingdee.eas.hr.base.HRBillStateEnum;
import com.kingdee.eas.hr.base.client.HRF7SingleChangePromptBoxFactory;
import com.kingdee.eas.hr.base.util.AdminTreeBuilder;
import com.kingdee.eas.hr.base.util.HRParamUtil;
import com.kingdee.eas.hr.base.util.HRTreeUtil;
import com.kingdee.eas.util.client.ComponentUtil;
import com.kingdee.eas.util.client.EASResource;
import com.kingdee.eas.util.client.ExceptionHandler;
import com.kingdee.eas.util.client.KDTableUtil;
import com.kingdee.eas.util.client.MsgBox;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.util.StringUtils;

public class EmployeeMutiF7UI extends AbstractEmployeeMutiF7UI {
	private String resClass = "com.kingdee.eas.basedata.org.client.PositionResource.";

	public boolean isCanceled = true;

	protected PersonInfo personInfo = null;

	protected PersonCollection personInfos = new PersonCollection();

	private HashSet selectPersonSet = new HashSet();

	private Map selectPersonPositionMap = new HashMap();

	private HashMap selPersonUnitMap = new HashMap();

	private HashMap selPersonPositionMap = new HashMap();

	private boolean loaded = false;

	private boolean isSingleSelect = true;

	private boolean isUpgrade = false;

	private boolean isOnlyPlurality = false;
	public static final String IS_Only_Plurality = "FROM_PAGE";
	public static final String IS_SINGLE_SELECT = "IS_SINGLE_SELECT";
	public static final String SHOW_PAYPERSON = "SHOW_PAYPERSON";
	public static final String SHOW_SOCIETY = "SHOW_SOCIETY";
	public static final String SHOW_TRYOUTPERSON = "SHOW_TRYOUTPERSON";
	public static final String SHOW_NO_POSITION_PERSON = "SHOW_NO_POSITION_PERSON";
	public static final String NO_POSOTION_PERSON_FILTER = "NO_POSOTION_PERSON_FILTER";
	public static final String RETURN_POSITION_UNIT = "RETURN_POSITION_UNIT";
	public static final String SHOW_CADRE = "SHOW_CADRE";
	public static final String HIDE_ADMINTREE_TAB = "hideAdminTreeTab";
	public static final String IS_HR_FILTER = "IS_HR_FILTER";
	public static final String IS_SHOW_ALL_ADMIN = "IS_SHOW_ALL_ADMIN";
	public static final String SHOW_USER_ORG_RANGE = "SHOW_USER_ORG_RANGE";
	public static final String DEFAULT_POSITION = "DEFAULT_POSITION";
	public static final String HRO_SET = "HRO_SET";
	public static final String SHOW_CHECK_HIRE_PERSON = "SHOW_CHECK_HIRE_PERSON";
	public static final String IS_PLURALITY_IS_CHOOSE_CONTRAL = "IS_PLURALITY_IS_CHOOSE_CONTRAL";
	private boolean isPlurality = true;

	private HashSet hroSet = null;

	private boolean isHRFilter = false;

	private boolean isShowUserOrgRange = false;

	private boolean isShowAllAdmin = false;

	private FilterInfo noPositionPersonFilter = null;

	private boolean isHideAdminTreeTab = false;
	private boolean returnPositionUnit = true;

	private boolean isDistabled = true;

	private boolean isMaxSize = false;

	private Rectangle winSize = null;

	private boolean isProbationHire = false;

	private boolean isProbationResign = false;

	private boolean isContractResgin = false;

	public EmployeeMutiF7UI() throws Exception {
	}

	protected String getEditUIName() {
		return null;
	}

	protected ICoreBase getBizInterface() throws Exception {
		return null;
	}

	protected JButton getDefaultButton() {
		return this.btnConfirm;
	}

	public void actionRefresh_actionPerformed(ActionEvent e) throws Exception {
		this.tblMain.removeRows();
	}

	public void actionRemove_actionPerformed(ActionEvent e) throws Exception {
	}

	protected void initWorkButton() {
		super.initWorkButton();
		this.txtValue.setFilterType(-1);
		this.kdContainer.addButton(this.btnInertRow);
		this.kdContainer.addButton(this.btnDeleteRow);
		this.kdContainer.addButton(this.btnInsertBatchRow);
		this.kdContainer.addButton(this.btnDeleteBatchRow);
		this.treeMain.setShowsRootHandles(true);
		this.treeMain2.setShowsRootHandles(true);
		this.tblMain.getStyleAttributes().setLocked(true);
		this.tblSelectPerson.getStyleAttributes().setLocked(true);
		this.tblMain.getDataRequestManager().addDataFillListener(
				new KDTDataFillListener() {
					public void afterDataFill(KDTDataRequestEvent e) {
						if (EmployeeMutiF7UI.this.tblMain.getRowCount() != 0) {
							EmployeeMutiF7UI.this.tblMain.getSelectManager()
									.select(0, 0);
						}
					}
				});
		this.tblSelectPerson.getDataRequestManager().addDataFillListener(
				new KDTDataFillListener() {
					public void afterDataFill(KDTDataRequestEvent e) {
						if (EmployeeMutiF7UI.this.tblSelectPerson.getRowCount() != 0) {
							EmployeeMutiF7UI.this.tblSelectPerson
									.getSelectManager().select(0, 0);
						}
					}
				});
		this.tabTree.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				try {
					if (("treeView2".equals(EmployeeMutiF7UI.this.tabTree
							.getSelectedComponent().getName()))
							&& (!EmployeeMutiF7UI.this.loaded)) {
						EmployeeMutiF7UI.this.chkShowVirtualOrg
								.setVisible(false);

						EmployeeMutiF7UI.this.initEmpFenLeiTree();
						// EmployeeMutiF7UIPIEx
						// .access$202(EmployeeMutiF7UIPIEx.this, true);
					}
					if ("treeView1".equals(EmployeeMutiF7UI.this.tabTree
							.getSelectedComponent().getName())) {
						EmployeeMutiF7UI.this.treeMain_valueChanged(null);
						EmployeeMutiF7UI.this.chkShowVirtualOrg
								.setVisible(true);
					} else {
						EmployeeMutiF7UI.this.treeMain2_valueChanged(null);
						EmployeeMutiF7UI.this.chkShowVirtualOrg
								.setVisible(false);
					}
				} catch (Exception e1) {
					ExceptionHandler.handle(EmployeeMutiF7UI.this.treeMain, e1);
				}
			}
		});
	}

	public void onLoad() throws Exception {
		this.isDistabled = HRParamUtil.getParamOfHR(null, "IS_AFFAIR", null);

		this.isUpgrade = AffairUpgradeFacadeFactory.getRemoteInstance()
				.isUpgrade();

		HashMap map = (HashMap) getUIContext();

		if ((map.get("FROM_PAGE") != null)
				&& ((map.get("FROM_PAGE") instanceof Boolean))) {
			this.isOnlyPlurality = ((Boolean) map.get("FROM_PAGE"))
					.booleanValue();
		}

		if ((map.get("IS_PLURALITY_IS_CHOOSE_CONTRAL") != null)
				&& ((map.get("IS_PLURALITY_IS_CHOOSE_CONTRAL") instanceof Boolean))) {
			this.isPlurality = ((Boolean) map
					.get("IS_PLURALITY_IS_CHOOSE_CONTRAL")).booleanValue();
		}

		if (map.get("HRO_SET") != null) {
			this.hroSet = ((HashSet) map.get("HRO_SET"));
		}

		if ((map.get("IS_SINGLE_SELECT") != null)
				&& ((map.get("IS_SINGLE_SELECT") instanceof Boolean))) {
			this.isSingleSelect = ((Boolean) map.get("IS_SINGLE_SELECT"))
					.booleanValue();
		}

		if ((map.get("IS_HR_FILTER") != null)
				&& ((map.get("IS_HR_FILTER") instanceof Boolean))) {
			this.isHRFilter = ((Boolean) map.get("IS_HR_FILTER"))
					.booleanValue();
		}

		if ((map.get("IS_SHOW_ALL_ADMIN") != null)
				&& ((map.get("IS_SHOW_ALL_ADMIN") instanceof Boolean))) {
			this.isShowAllAdmin = ((Boolean) map.get("IS_SHOW_ALL_ADMIN"))
					.booleanValue();
		}

		if ((map.get("RETURN_POSITION_UNIT") != null)
				&& ((map.get("RETURN_POSITION_UNIT") instanceof Boolean))) {
			this.returnPositionUnit = ((Boolean) map
					.get("RETURN_POSITION_UNIT")).booleanValue();
		}

		if ((map.get("SHOW_USER_ORG_RANGE") != null)
				&& ((map.get("SHOW_USER_ORG_RANGE") instanceof Boolean))) {
			this.isShowUserOrgRange = ((Boolean) map.get("SHOW_USER_ORG_RANGE"))
					.booleanValue();
		}
		if ((map.get("NO_POSOTION_PERSON_FILTER") != null)
				&& ((map.get("NO_POSOTION_PERSON_FILTER") instanceof FilterInfo))) {
			this.noPositionPersonFilter = ((FilterInfo) map
					.get("NO_POSOTION_PERSON_FILTER"));
		}
		if (Boolean.valueOf(true).equals(map.get("hideAdminTreeTab"))) {
			this.isHideAdminTreeTab = true;
		}
		super.onLoad();

		this.tblSelectPerson.checkParsed();

		if (this.isSingleSelect) {
			this.kDSplitPane2.remove(this.kdContainer);
			this.kDSplitPane2.setDividerSize(0);
			this.tblMain.getSelectManager().setSelectMode(2);
		} else {
			this.tblMain.getSelectManager().setSelectMode(10);
			this.tblSelectPerson.getSelectManager().setSelectMode(10);
		}

		if (((map.get("SHOW_NO_POSITION_PERSON") != null)
				&& ((map.get("SHOW_NO_POSITION_PERSON") instanceof Boolean)) && (!((Boolean) map
				.get("SHOW_NO_POSITION_PERSON")).booleanValue()))
				|| (map.get("SHOW_NO_POSITION_PERSON") == null)) {
			this.tabTree.removeTabAt(1);
		}

		if (Boolean.valueOf(true).equals(map.get("hideAdminTreeTab"))) {
			this.tabTree.setSelectedIndex(1);
			this.tabTree.removeTabAt(0);
		}

		if (!this.isHideAdminTreeTab) {
			initAdminTree();
		}

		this.kdContainer.getContentPane().putClientProperty("OriginalBounds",
				new Rectangle(0, 0, 415, 135));

		this.txtValue.setText("");
		CtrlSwingUtilities.removeManagingFocusForwardTraversalKeys(
				this.txtValue, KeyStroke.getKeyStroke(10, 0));
		this.txtValue.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					EmployeeMutiF7UI.this.btnFastQuery_actionPerformed(e);
				} catch (Exception e1) {
					EmployeeMutiF7UI.this.handUIException(e1);
				}
			}
		});
		KDTableHelper.releaseEnterAndTab(this.tblMain);
		KDTableHelper.releaseEnterAndTab(this.tblSelectPerson);
		this.tblMain.getInputMap().remove(KeyStroke.getKeyStroke(10, 0));
		CtrlSwingUtilities.removeManagingFocusForwardTraversalKeys(
				this.tblMain, KeyStroke.getKeyStroke(10, 0));
		CtrlSwingUtilities.removeManagingFocusForwardTraversalKeys(
				this.tblSelectPerson, KeyStroke.getKeyStroke(10, 0));

		setDefaultPositionNode();

		initAction();
		this.chkShowVirtualOrg.setVisible(false);
	}

	private void setDefaultPositionNode() {
		PositionInfo position = (PositionInfo) getUIContext().get(
				"DEFAULT_POSITION");
		if (position == null) {
			return;
		}

		DefaultKingdeeTreeNode root = (DefaultKingdeeTreeNode) this.treeMain
				.getModel().getRoot();
		if (root == null) {
			return;
		}

		DefaultKingdeeTreeNode node = null;
		PositionInfo holdPosition = null;
		Enumeration e = root.breadthFirstEnumeration();
		while (e.hasMoreElements()) {
			node = (DefaultKingdeeTreeNode) e.nextElement();
			if (!(node.getUserObject() instanceof PositionInfo)) {
				continue;
			}

			holdPosition = (PositionInfo) node.getUserObject();
			if (!holdPosition.getId().equals(position.getId())) {
				continue;
			}
		}

		if (node != null) {
			this.treeMain.expandAllNodes(true, node);
			this.treeMain.setSelectionNode(node);
		}
	}

	private void initAdminTree() throws Exception {
		DefaultKingdeeTreeNode rootNode = null;

		if (this.isHRFilter) {
			rootNode = NewOrgTreeHelper.createAdminTreeNodeByHRO(null, false,
					true, false, this.chkShowVirtualOrg.isSelected());
		} else if (this.isShowAllAdmin) {
			rootNode = NewOrgTreeHelper.createAllAdminTreeNode(false, false,
					true, this.chkShowVirtualOrg.isSelected());
		} else {
			if (this.isShowUserOrgRange) {
				AdminTreeBuilder treeBuilder = null;
				if ((this.hroSet == null) || (this.hroSet.size() == 0)) {
					treeBuilder = new AdminTreeBuilder();
				} else {
					treeBuilder = new AdminTreeBuilder(true, this.hroSet);
				}
				treeBuilder.setShowVirtualOrg(this.chkShowVirtualOrg
						.isSelected());
				treeBuilder.buildTree(this.treeMain, true);
				if (this.treeMain.getModel() != null) {
					this.treeMain
							.setSelectionNode((DefaultKingdeeTreeNode) this.treeMain
									.getModel().getRoot());
				}
				return;
			}
			rootNode = NewOrgTreeHelper.createAdminTreeNodeByHRO(null, true,
					true, false, this.chkShowVirtualOrg.isSelected());
		}
		if (rootNode == null) {
			this.treeMain.setModel(null);
			return;
		}
		this.treeMain.setModel(new DefaultTreeModel(rootNode));
		if ((!OrgF7InnerUtils.isTreeNodeDisable(rootNode))
				|| (rootNode.getChildCount() == 0)) {
			TreePath path = new TreePath(rootNode.getPath());
			this.treeMain.expandPath(path);
			this.treeMain.setSelectionPath(path);
		} else {
			DefaultKingdeeTreeNode node = (DefaultKingdeeTreeNode) rootNode
					.getChildAt(0);
			TreePath path = new TreePath(node.getPath());
			this.treeMain.expandPath(path);
			this.treeMain.setSelectionPath(path);
		}
	}

	private void initEmpFenLeiTree() throws Exception {
		DefaultKingdeeTreeNode rootNode = HRTreeUtil
				.createEmployeeFenLeiTreeNode(true);
		DefaultTreeModel model = new DefaultTreeModel(rootNode);
		this.treeMain2.setModel(model);
		this.treeMain2.expandAllNodes(true, rootNode);
		this.treeMain2.setSelectionNode(rootNode);
		this.treeMain2.setShowsRootHandles(true);
	}

	protected void btnQuit_actionPerformed(ActionEvent e) throws Exception {
		super.btnQuit_actionPerformed(e);

		this.isCanceled = true;
		getUIWindow().close();
	}

	private void setReturnPositionAndUnit(String pId, int index)
			throws Exception {
		if (this.tblMain.getRow(index).getCell("adminUnitId").getValue() != null) {
			AdminOrgUnitInfo adminInfo = new AdminOrgUnitInfo();
			Object v = null;
			IRow row = this.tblMain.getRow(index);
			adminInfo.setId(BOSUuid.read(row.getCell("adminUnitId").getValue()
					.toString()));
			adminInfo.setName(row.getCell("adminUnit").getValue().toString());
			v = row.getCell("adminDisName").getValue();
			if (v != null) {
				adminInfo.setDisplayName(v.toString());
			}
			this.selPersonUnitMap.put(pId, adminInfo);
		}

		if (this.tblMain.getRow(index).getCell("positionId").getValue() != null) {
			PositionInfo posiInfo = new PositionInfo();
			posiInfo.setId(BOSUuid.read(this.tblMain.getRow(index).getCell(
					"positionId").getValue().toString()));
			posiInfo.setName(this.tblMain.getRow(index).getCell("position")
					.getValue().toString());
			this.selPersonPositionMap.put(pId, posiInfo);
		}
	}

	protected void btnConfirm_actionPerformed(ActionEvent e) throws Exception {
		if (this.isSingleSelect) {
			int[] rowID = KDTableUtil.getSelectedRows(this.tblMain);
			if (rowID.length > 0) {
				String strID = this.tblMain.getRow(rowID[0]).getCell("id")
						.getValue().toString();
				this.selectPersonSet = new HashSet();
				this.selPersonUnitMap = new HashMap();
				this.selPersonPositionMap = new HashMap();
				this.selectPersonSet.add(strID);
				addPersonSelectPositionMap(rowID[0]);
				setReturnPositionAndUnit(strID, rowID[0]);
			}
		}

		if ((this.selectPersonSet == null)
				|| (this.selectPersonSet.size() == 0)) {
			MsgBox.showInfo(EASResource.getString(this.resClass
					+ "NO_SELECT_ROW"));
			return;
		}

		IRowSet rows = BaseInnerFacadeFactory.getRemoteInstance()
				.getSelectPersonRowSet(
						"com.kingdee.eas.hr.emp.app.EmployeeF7SelectQuery",
						this.selectPersonSet);

		while (rows.next()) {
			this.personInfos.add(getPersonInfo(rows));
		}

		if ((this.isSingleSelect) && (this.personInfos.size() > 0)) {
			this.personInfo = this.personInfos.get(0);
		}

		this.isCanceled = false;
		getUIWindow().close();
	}

	private PersonInfo getPersonInfo(IRowSet rows) throws Exception {
		PersonInfo pInfo = new PersonInfo();
		pInfo.setId(BOSUuid.read(rows.getString("id")));
		pInfo.setNumber(rows.getString("number"));
		pInfo.setName(rows.getString("name"));
		pInfo.setIdCardNO(rows.getString("idCardNO"));
		pInfo.setPassportNO(rows.getString("passportNO"));
		if (Genders.getEnum(rows.getInt("gender")) != null) {
			pInfo.setGender(Genders.getEnum(rows.getInt("gender")));
		}
		pInfo.setEmail(rows.getString("email"));

		if (!this.returnPositionUnit) {
			if (this.selPersonUnitMap.get(pInfo.getId().toString()) != null) {
				pInfo.put("primaryAdminOrg",
						(AdminOrgUnitInfo) this.selPersonUnitMap.get(pInfo
								.getId().toString()));
			}
			if (this.selPersonUnitMap.get(pInfo.getId().toString()) != null) {
				pInfo.put("primaryPosition",
						(PositionInfo) this.selPersonPositionMap.get(pInfo
								.getId().toString()));
			}
		} else {
			if (rows.getBoolean("PositionMember.isPrimary")) {
				pInfo.put("primaryAdminOrg", getAdminOrgUnitInfo(rows));
				pInfo.put("primaryPosition", getPositionInfo(rows));
			}

			if (pInfo.get("primaryAdminOrg") == null) {
				pInfo.put("primaryAdminOrg", getAdminOrgUnitInfo(rows));
			}
		}
		pInfo.put("personSelectPosition", this.selectPersonPositionMap
				.get(pInfo.getId().toString()));
		if (rows.getDate("SocialInsurance.tranSInsuTime") != null) {
			pInfo.put("STime", rows.getDate("SocialInsurance.tranSInsuTime"));
		}
		pInfo.put("employeeClassify", rows.getString("employeeClassify.name"));

		return pInfo;
	}

	private AdminOrgUnitInfo getAdminOrgUnitInfo(IRowSet rows) throws Exception {
		AdminOrgUnitInfo adminInfo = null;
		if (rows.getString("AdminOrgUnit.id") != null) {
			adminInfo = new AdminOrgUnitInfo();
			adminInfo.setId(BOSUuid.read(rows.getString("AdminOrgUnit.id")));
			adminInfo.setNumber(rows.getString("AdminOrgUnit.number"));
			adminInfo.setName(rows.getString("AdminOrgUnit.name"));
			adminInfo.setLevel(rows.getInt("AdminOrgUnit.level"));
			adminInfo.setLongNumber(rows.getString("AdminOrgUnit.longNumber"));
			adminInfo
					.setDisplayName(rows.getString("AdminOrgUnit.displayName"));
		}
		return adminInfo;
	}

	private PositionInfo getPositionInfo(IRowSet rows) throws Exception {
		PositionInfo posiInfo = new PositionInfo();
		if (rows.getString("Position.id") != null) {
			posiInfo = new PositionInfo();
			posiInfo.setId(BOSUuid.read(rows.getString("Position.id")));
			posiInfo.setNumber(rows.getString("Position.number"));
			posiInfo.setName(rows.getString("Position.name"));
		}
		return posiInfo;
	}

	protected void btnDeleteBatchRow_actionPerformed(ActionEvent e)
			throws Exception {
		super.btnDeleteBatchRow_actionPerformed(e);

		this.tblSelectPerson.removeRows();

		this.selectPersonSet = new HashSet();
		this.selPersonUnitMap = new HashMap();
		this.selPersonPositionMap = new HashMap();
	}

	protected void btnDeleteRow_actionPerformed(ActionEvent e) throws Exception {
		super.btnDeleteRow_actionPerformed(e);

		int[] rowID = KDTableUtil.getSelectedRows(this.tblSelectPerson);

		delDataFromSelectTable(rowID);
	}

	protected void btnFastQuery_actionPerformed(ActionEvent e) throws Exception {
		super.btnFastQuery_actionPerformed(e);

		FilterInfo filterInfo = new FilterInfo();

		if (this.cboKey.getSelectedIndex() == 0) {
			if (this.chkLike.isSelected()) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("name", "%"
								+ this.txtValue.getText().trim() + "%",
								CompareType.LIKE));
			} else
				filterInfo.getFilterItems().add(
						new FilterItemInfo("name", this.txtValue.getText()
								.trim()));
		} else if (this.cboKey.getSelectedIndex() == 1) {
			if (this.chkLike.isSelected()) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("number", "%"
								+ this.txtValue.getText().trim() + "%",
								CompareType.LIKE));
			} else
				filterInfo.getFilterItems().add(
						new FilterItemInfo("number", this.txtValue.getText()
								.trim()));
		} else if (this.cboKey.getSelectedIndex() == 2) {
			if (this.chkLike.isSelected()) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("idNum", "%"
								+ this.txtValue.getText().trim() + "%",
								CompareType.LIKE));
			} else {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("idNum", this.txtValue.getText()
								.trim()));
			}
		}

		if (!this.isShowAllAdmin) {
			if ((this.hroSet != null) && (this.hroSet.size() > 0)) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("ToUnit.id", this.hroSet,
								CompareType.INCLUDE));
				filterInfo
						.getFilterItems()
						.add(
								new FilterItemInfo("TypeRela.id",
										"00000000-0000-0000-0000-0000000000100FE9F8B5"));
			} else if (!this.isShowUserOrgRange) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("ToUnit.id", SysContext
								.getSysContext().getCurrentHRUnit().getId()
								.toString()));
				filterInfo
						.getFilterItems()
						.add(
								new FilterItemInfo("TypeRela.id",
										"00000000-0000-0000-0000-0000000000100FE9F8B5"));
			}

			if (!this.isHRFilter) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("PMUser.id", SysContext
								.getSysContext().getCurrentUserInfo().getId()
								.toString()));
				filterInfo.getFilterItems().add(
						new FilterItemInfo("OrgRange.type", new Integer(20)));
			}
			addFilterPositionEnable(filterInfo);

			addFilterPositionMemberEnable(filterInfo);
		}
		FilterInfo filterSealUp = new FilterInfo("AdminOrgUnit.isSealUp = 0");
		filterInfo.mergeFilter(filterSealUp, "and");
		this.mainQuery = new EntityViewInfo();
		this.mainQuery.setFilter(filterInfo);

		getCustomFilter();

		this.tblMain.removeRows();
		this.tblMain.requestFocusInWindow();
	}

	private void addFilterPositionEnable(FilterInfo filter) throws Exception {
		if (!this.isDistabled) {
			FilterInfo fi = new FilterInfo();
			fi.getFilterItems()
					.add(
							new FilterItemInfo("Position.deletedStatus",
									new Integer(1)));
			fi.getFilterItems().add(
					new FilterItemInfo("Position.deletedStatus", null));
			fi.setMaskString("#0 or #1");
			if ((filter != null) && (filter.getFilterItems().size() > 0))
				filter.mergeFilter(fi, "and");
			else
				filter = fi;
		}
	}

	private void addFilterPositionMemberEnable(FilterInfo filter)
			throws Exception {
		if (!this.isPlurality) {
			FilterInfo fi = new FilterInfo();
			fi.getFilterItems().add(
					new FilterItemInfo("PositionMember.isPrimary", new Integer(
							1)));
			if ((filter != null) && (filter.getFilterItems().size() > 0))
				filter.mergeFilter(fi, "and");
			else
				filter = fi;
		}
	}

	private void getCustomFilter() throws Exception {
		initAction();
		if ((this.mainQuery.getFilter() != null)
				&& (this.mainQuery.getFilter().getFilterItems() != null)) {
			int flag = 0;
			if ((getUIContext().get("SHOW_PAYPERSON") != null)
					&& ((getUIContext().get("SHOW_PAYPERSON") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_PAYPERSON"))
						.booleanValue())
					flag = 1;
				else
					flag = 0;
				FilterInfo ffInfo = new FilterInfo();
				ffInfo.getFilterItems().add(
						new FilterItemInfo("PersonCMP.isPayPerson",
								new Integer(flag)));
				this.mainQuery.getFilter().mergeFilter(ffInfo, "and");
			}
			if ((getUIContext().get("SHOW_TRYOUTPERSON") != null)
					&& ((getUIContext().get("SHOW_TRYOUTPERSON") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_TRYOUTPERSON"))
						.booleanValue())
					flag = 1;
				else
					flag = 0;
				if (flag == 1) {
					FilterInfo ffInfo = new FilterInfo();
					ffInfo
							.getFilterItems()
							.add(
									new FilterItemInfo("EmployeeType.id",
											"00000000-0000-0000-0000-000000000002A29E85B3"));

					if (this.isProbationHire) {
						ffInfo
								.getFilterItems()
								.add(
										new FilterItemInfo(
												"probationEntry.evaluationResult",
												EvaluationResultEnum.REGULARIZATION_VALUE,
												CompareType.EQUALS));
						ffInfo.getFilterItems().add(
								new FilterItemInfo(
										"probationEntry.probation.billState",
										HRBillStateEnum.AUDITED_VALUE,
										CompareType.EQUALS));

						ffInfo.setMaskString("#0 and #1 and #2");
					}
					this.mainQuery.getFilter().mergeFilter(ffInfo, "and");
				}
			}
			if ((getUIContext().get("SHOW_SOCIETY") != null)
					&& ((getUIContext().get("SHOW_SOCIETY") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_SOCIETY"))
						.booleanValue())
					flag = 1;
				else
					flag = 0;
				FilterInfo ffInfo = new FilterInfo();
				ffInfo.getFilterItems().add(
						new FilterItemInfo("SocialInsurance.isSocialInsu",
								new Integer(flag)));
				this.mainQuery.getFilter().mergeFilter(ffInfo, "and");
			}

			if ((getUIContext().get("SHOW_CADRE") != null)
					&& ((getUIContext().get("SHOW_CADRE") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_CADRE")).booleanValue())
					flag = 1;
				else
					flag = 0;
				if (flag == 1) {
					FilterInfo filter = new FilterInfo();
					filter.getFilterItems().add(
							new FilterItemInfo("isStandbyCadre", new Integer(
									flag)));
					this.mainQuery.getFilter().mergeFilter(filter, "and");
				}
			}

			if (this.noPositionPersonFilter != null) {
				this.mainQuery.getFilter().mergeFilter(
						this.noPositionPersonFilter, "and");
			}
			if (("treeView1".equals(this.tabTree.getSelectedComponent()
					.getName()))
					&& (!this.chkShowVirtualOrg.isSelected())) {
				FilterInfo isVirtualFilter = new FilterInfo(
						"AdminOrgUnit.isVirtual = 0");
				this.mainQuery.getFilter().mergeFilter(isVirtualFilter, "and");
			}

			if (this.isOnlyPlurality) {
				String sql = "SELECT T_ORG_PositionMember.fpersonid FROM T_ORG_PositionMember INNER JOIN T_ORG_Position ON T_ORG_PositionMember.FPositionID = T_ORG_Position.FID INNER JOIN T_ORG_Admin ON T_ORG_Position.FAdminOrgUnitID = T_ORG_Admin.FID WHERE T_ORG_PositionMember.FISPRIMARY = 0";

				FilterInfo pluralityFilter = new FilterInfo("id in (" + sql
						+ ")");
				this.mainQuery.getFilter().mergeFilter(pluralityFilter, "and");
			}

			if (((getUIContext().get("SHOW_CHECK_HIRE_PERSON") instanceof Boolean))
					&& (((Boolean) getUIContext().get("SHOW_CHECK_HIRE_PERSON"))
							.booleanValue())) {
				FilterInfo filter = new FilterInfo();
				filter.getFilterItems().add(
						new FilterItemInfo("PositionMember.checkState", "2",
								CompareType.NOTEQUALS));
				filter.getFilterItems().add(
						new FilterItemInfo("PositionMember.checkState", null,
								CompareType.IS));
				filter.setMaskString("#0 or #1");
				this.mainQuery.getFilter().mergeFilter(filter, "and");
			}
			if (this.isContractResgin) {
				// FilterInfo filter = new FilterInfo();
				// filter.getFilterItems().add(
				// new FilterItemInfo("entrys.deptopt",
				// DeptOptEnum.TERMINATION_VALUE,
				// CompareType.EQUALS));
				// filter.getFilterItems().add(
				// new FilterItemInfo("billstate",
				// HRBillStateEnum.AUDITED_VALUE,
				// CompareType.EQUALS));
				//
				// filter.setMaskString("#0 and #1");
				//
				EntityViewInfo view = new EntityViewInfo();
				SelectorItemCollection selectors = new SelectorItemCollection();
				selectors.add("person.id");
				view.setSelector(selectors);
				// view.setFilter(filter);
				IRowSet rs = this
						.getQueryExecutor(
								new MetaDataPK(
										"com.kingdee.eas.custom.hr.affair.contract.app.ContractEvalQuery"),
								view).executeQuery();

				Set set = new HashSet();
				set.add("");
				while (rs.next()) {
					set.add(rs.getString("person.id"));
				}
				FilterInfo fi = new FilterInfo();
				fi.getFilterItems().add(
						new FilterItemInfo("id", set, CompareType.INNER));
				this.mainQuery.getFilter().mergeFilter(fi, "AND");
			}

			if (this.isProbationResign) {
				FilterInfo filter = new FilterInfo();
				filter.getFilterItems().add(
						new FilterItemInfo("probationEntry.evaluationResult",
								EvaluationResultEnum.DISMISS_VALUE,
								CompareType.EQUALS));
				filter.getFilterItems().add(
						new FilterItemInfo(
								"probationEntry.probation.billState",
								HRBillStateEnum.AUDITED_VALUE,
								CompareType.EQUALS));

				filter.setMaskString("#0 and #1");

				this.mainQuery.getFilter().mergeFilter(filter, "AND");
			}
		}
	}

	protected void btnInertRow_actionPerformed(ActionEvent e) throws Exception {
		super.btnInertRow_actionPerformed(e);

		int[] rowID = KDTableUtil.getSelectedRows(this.tblMain);

		addDataToSelectTable(rowID);
	}

	protected void btnInsertBatchRow_actionPerformed(ActionEvent e)
			throws Exception {
		super.btnInsertBatchRow_actionPerformed(e);

		int[] rowID = null;
		if (this.tblMain.getRowCount() == -1) {
			rowID = new int[100];
		} else {
			rowID = new int[this.tblMain.getRowCount()];
		}

		for (int i = 0; i < rowID.length; i++) {
			rowID[i] = i;
		}
		addDataToSelectTable(rowID);
	}

	private void setCommonQueryPK() throws Exception {
		CommonQueryDialog commonDialog = getDialog();
		if (commonDialog != null)
			commonDialog.setQueryObjectPK(this.mainQueryPK);
	}

	protected void treeMain_valueChanged(TreeSelectionEvent e) throws Exception {
		super.treeMain_valueChanged(e);
		initAction();
		if (this.isHideAdminTreeTab) {
			return;
		}
		if (this.isHRFilter)
			this.mainQueryPK = new MetaDataPK("com.kingdee.eas.hr.emp.app",
					"EmployeeF7ByHRQuery");
		else if (this.isShowAllAdmin) {
			this.mainQueryPK = new MetaDataPK("com.kingdee.eas.hr.emp.app",
					"EmployeeF7ByAllAdminQuery");
		} else if (this.isUpgrade)
			this.mainQueryPK = new MetaDataPK("com.kingdee.eas.hr.emp.app",
					"EmployeeF7Query");
		else {
			this.mainQueryPK = new MetaDataPK("com.kingdee.eas.hr.emp.app",
					"EmployeeF7OldQuery");
		}
		TreePath path = this.treeMain.getSelectionPath();
		if (path == null)
			return;
		DefaultKingdeeTreeNode treenode = (DefaultKingdeeTreeNode) path
				.getLastPathComponent();

		FilterInfo filter = new FilterInfo();
		this.mainQuery = new EntityViewInfo();

		if ((OrgF7InnerUtils.isTreeNodeDisable(treenode))
				|| (HRTreeUtil.isTreeNodeDisable(treenode))) {
			filter.getFilterItems().add(new FilterItemInfo("id", "nodata"));
			this.mainQuery.setFilter(filter);
			this.tblMain.removeRows();
			return;
		}

		if ((treenode.getUserObject() != null)
				&& ((treenode.getUserObject() instanceof AdminOrgUnitInfo))) {
			this.chkInclude.setVisible(true);

			AdminOrgUnitInfo nodeInfo = (AdminOrgUnitInfo) treenode
					.getUserObject();

			filter.getFilterItems().add(
					new FilterItemInfo("AdminOrgUnit.id", nodeInfo.getId()
							.toString()));
			if (this.chkInclude.isSelected()) {
				filter.getFilterItems().add(
						new FilterItemInfo("AdminOrgUnit.longNumber", nodeInfo
								.getLongNumber()
								+ "!%", CompareType.LIKE));
				filter.setMaskString("#0 or #1");
			}
		} else if ((treenode.getUserObject() != null)
				&& ((treenode.getUserObject() instanceof PositionInfo))) {
			this.chkInclude.setVisible(false);
			PositionInfo nodeInfo = (PositionInfo) treenode.getUserObject();
			filter.getFilterItems().add(
					new FilterItemInfo("Position.id", nodeInfo.getId()
							.toString()));
		}

		if (!this.isShowAllAdmin) {
			FilterInfo filterInfo = new FilterInfo();

			if ((this.hroSet != null) && (this.hroSet.size() > 0)) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("ToUnit.id", this.hroSet,
								CompareType.INCLUDE));
				filterInfo
						.getFilterItems()
						.add(
								new FilterItemInfo("TypeRela.id",
										"00000000-0000-0000-0000-0000000000100FE9F8B5"));
			} else if (!this.isShowUserOrgRange) {
				if (SysContext.getSysContext().getCurrentHRUnit() != null) {
					filterInfo.getFilterItems().add(
							new FilterItemInfo("ToUnit.id", SysContext
									.getSysContext().getCurrentHRUnit().getId()
									.toString()));
				} else {
					filterInfo.getFilterItems().add(
							new FilterItemInfo("ToUnit.id", "nodata"));
				}
				filterInfo
						.getFilterItems()
						.add(
								new FilterItemInfo("TypeRela.id",
										"00000000-0000-0000-0000-0000000000100FE9F8B5"));
			}

			if (!this.isHRFilter) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("PMUser.id", SysContext
								.getSysContext().getCurrentUserInfo().getId()
								.toString()));
				filterInfo.getFilterItems().add(
						new FilterItemInfo("OrgRange.type", new Integer(20)));
			}
			if (!StringUtils.isEmpty(filter.toString())) {
				filter.mergeFilter(filterInfo, "AND");
			} else {
				filter = filterInfo;
			}
		}

		addFilterPositionEnable(filter);

		addFilterPositionMemberEnable(filter);
		FilterInfo filterSealUp = new FilterInfo("AdminOrgUnit.isSealUp = 0");
		filter.mergeFilter(filterSealUp, "and");

		this.mainQuery.setFilter(filter);

		getCustomFilter();

		this.tblMain.removeRows();

		this.tblMain.reLayoutAndPaint();

		setCommonQueryPK();
	}

	protected void treeMain2_valueChanged(TreeSelectionEvent e)
			throws Exception {
		super.treeMain2_valueChanged(e);

		this.chkInclude.setVisible(false);

		TreePath path = this.treeMain2.getSelectionPath();
		if (path == null) {
			return;
		}

		DefaultKingdeeTreeNode selectNode = (DefaultKingdeeTreeNode) path
				.getLastPathComponent();

		if (this.isUpgrade) {
			this.mainQueryPK = new MetaDataPK("com.kingdee.eas.hr.emp.app",
					"EmployeeNoPosition2NewQuery");
		} else {
			this.mainQueryPK = new MetaDataPK("com.kingdee.eas.hr.emp.app",
					"EmployeeNoPosition2Query");
		}

		this.mainQuery = new EntityViewInfo();
		FilterInfo filter = new FilterInfo();

		if ((selectNode.getUserObject() instanceof EmployeeFenLeiInfo)) {
			EmployeeFenLeiInfo fenLeiInfo = (EmployeeFenLeiInfo) selectNode
					.getUserObject();
			filter.getFilterItems().add(
					new FilterItemInfo("EmpFenLei.longNumber", fenLeiInfo
							.getLongNumber()));
			filter.getFilterItems().add(
					new FilterItemInfo("EmpFenLei.longNumber", fenLeiInfo
							.getLongNumber()
							+ "!%", CompareType.LIKE));

			filter.setMaskString("#0 or #1");
		} else if ((selectNode.getUserObject() instanceof EmployeeTypeInfo)) {
			EmployeeTypeInfo typeInfo = (EmployeeTypeInfo) selectNode
					.getUserObject();
			filter.getFilterItems().add(
					new FilterItemInfo("employeeType.id", typeInfo.getId()
							.toString()));
		}

		if (!this.isShowAllAdmin) {
			FilterInfo filterInfo = new FilterInfo();
			filterInfo.getFilterItems().add(
					new FilterItemInfo("PMUser.id", SysContext.getSysContext()
							.getCurrentUserInfo().getId().toString()));
			filterInfo.getFilterItems().add(
					new FilterItemInfo("OrgRange.type", new Integer(20)));

			if ((this.hroSet != null) && (this.hroSet.size() > 0)) {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("ToUnit.id", this.hroSet,
								CompareType.INCLUDE));
				filterInfo
						.getFilterItems()
						.add(
								new FilterItemInfo("TypeRela.id",
										"00000000-0000-0000-0000-0000000000100FE9F8B5"));
			} else if (!this.isShowUserOrgRange) {
				if (SysContext.getSysContext().getCurrentHRUnit() != null) {
					filterInfo.getFilterItems().add(
							new FilterItemInfo("ToUnit.id", SysContext
									.getSysContext().getCurrentHRUnit().getId()
									.toString()));
				} else {
					filterInfo.getFilterItems().add(
							new FilterItemInfo("ToUnit.id", "nodata"));
				}
				filterInfo
						.getFilterItems()
						.add(
								new FilterItemInfo("TypeRela.id",
										"00000000-0000-0000-0000-0000000000100FE9F8B5"));
			}

			filter.mergeFilter(filterInfo, "and");
		}
		this.mainQuery.setFilter(filter);
		getCustomFilter();
		this.tblMain.removeRows();

		this.tblMain.reLayoutAndPaint();

		setCommonQueryPK();
	}

	protected FilterInfo getDefaultFilterForQuery() {
		FilterInfo filterInfo = new FilterInfo();
		try {
			if (!this.isShowAllAdmin) {
				if ((this.hroSet != null) && (this.hroSet.size() > 0)) {
					filterInfo.getFilterItems().add(
							new FilterItemInfo("ToUnit.id", this.hroSet,
									CompareType.INCLUDE));
					filterInfo
							.getFilterItems()
							.add(
									new FilterItemInfo("TypeRela.id",
											"00000000-0000-0000-0000-0000000000100FE9F8B5"));
				} else if (!this.isShowUserOrgRange) {
					if (SysContext.getSysContext().getCurrentHRUnit() != null) {
						filterInfo.getFilterItems().add(
								new FilterItemInfo("ToUnit.id", SysContext
										.getSysContext().getCurrentHRUnit()
										.getId().toString()));
					} else {
						filterInfo.getFilterItems().add(
								new FilterItemInfo("ToUnit.id", "nodata"));
					}
					filterInfo
							.getFilterItems()
							.add(
									new FilterItemInfo("TypeRela.id",
											"00000000-0000-0000-0000-0000000000100FE9F8B5"));
				}

				if (!this.isHRFilter) {
					filterInfo.getFilterItems().add(
							new FilterItemInfo("PMUser.id", SysContext
									.getSysContext().getCurrentUserInfo()
									.getId().toString()));
					filterInfo.getFilterItems()
							.add(
									new FilterItemInfo("OrgRange.type",
											new Integer(20)));
				}

				addFilterPositionEnable(filterInfo);

				addFilterPositionMemberEnable(filterInfo);
			}

			int flag = 0;
			if ((getUIContext().get("SHOW_PAYPERSON") != null)
					&& ((getUIContext().get("SHOW_PAYPERSON") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_PAYPERSON"))
						.booleanValue())
					flag = 1;
				else
					flag = 0;
				FilterInfo ffInfo = new FilterInfo();
				ffInfo.getFilterItems().add(
						new FilterItemInfo("PersonCMP.isPayPerson",
								new Integer(flag)));
				if (filterInfo.getFilterItems().size() > 0)
					filterInfo.mergeFilter(ffInfo, "and");
				else
					filterInfo = ffInfo;
			}
			if ((getUIContext().get("SHOW_TRYOUTPERSON") != null)
					&& ((getUIContext().get("SHOW_TRYOUTPERSON") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_TRYOUTPERSON"))
						.booleanValue())
					flag = 1;
				else
					flag = 0;
				if (flag == 1) {
					FilterInfo ffInfo = new FilterInfo();
					ffInfo
							.getFilterItems()
							.add(
									new FilterItemInfo("EmployeeType.id",
											"00000000-0000-0000-0000-000000000002A29E85B3"));
					if (filterInfo.getFilterItems().size() > 0)
						filterInfo.mergeFilter(ffInfo, "and");
					else
						filterInfo = ffInfo;
				}
			}
			if ((getUIContext().get("SHOW_SOCIETY") != null)
					&& ((getUIContext().get("SHOW_SOCIETY") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_SOCIETY"))
						.booleanValue())
					flag = 1;
				else
					flag = 0;
				FilterInfo ffInfo = new FilterInfo();
				ffInfo.getFilterItems().add(
						new FilterItemInfo("SocialInsurance.isSocialInsu",
								new Integer(flag)));
				if (filterInfo.getFilterItems().size() > 0)
					filterInfo.mergeFilter(ffInfo, "and");
				else {
					filterInfo = ffInfo;
				}
			}
			if ((getUIContext().get("SHOW_CADRE") != null)
					&& ((getUIContext().get("SHOW_CADRE") instanceof Boolean))) {
				if (((Boolean) getUIContext().get("SHOW_CADRE")).booleanValue())
					flag = 1;
				else
					flag = 0;
				if (flag == 1) {
					FilterInfo filter = new FilterInfo();
					filter.getFilterItems().add(
							new FilterItemInfo("isStandbyCadre", new Integer(
									flag)));
					if (filterInfo.getFilterItems().size() > 0) {
						filterInfo.mergeFilter(filter, "and");
					} else {
						filterInfo = filter;
					}
				}
			}

			if (this.noPositionPersonFilter != null) {
				filterInfo.mergeFilter(this.noPositionPersonFilter, "and");
			}
			FilterInfo filterSealUp = new FilterInfo(
					"AdminOrgUnit.isSealUp = 0");
			filterInfo.mergeFilter(filterSealUp, "and");
			if (("treeView1".equals(this.tabTree.getSelectedComponent()
					.getName()))
					&& (!this.chkShowVirtualOrg.isSelected())) {
				FilterInfo isVirtualFilter = new FilterInfo(
						"AdminOrgUnit.isVirtual = 0");
				filterInfo.mergeFilter(isVirtualFilter, "and");
			}

			if (this.isOnlyPlurality) {
				String sql = "SELECT T_ORG_PositionMember.fpersonid FROM T_ORG_PositionMember INNER JOIN T_ORG_Position ON T_ORG_PositionMember.FPositionID = T_ORG_Position.FID INNER JOIN T_ORG_Admin ON T_ORG_Position.FAdminOrgUnitID = T_ORG_Admin.FID WHERE T_ORG_PositionMember.FISPRIMARY = 0";

				FilterInfo pluralityFilter = new FilterInfo("id in (" + sql
						+ ")");
				filterInfo.mergeFilter(pluralityFilter, "and");
			}

			if (((getUIContext().get("SHOW_CHECK_HIRE_PERSON") instanceof Boolean))
					&& (((Boolean) getUIContext().get("SHOW_CHECK_HIRE_PERSON"))
							.booleanValue())) {
				FilterInfo filter = new FilterInfo();
				filter.getFilterItems().add(
						new FilterItemInfo("PositionMember.checkState", "2",
								CompareType.NOTEQUALS));
				filter.getFilterItems().add(
						new FilterItemInfo("PositionMember.checkState", null,
								CompareType.IS));
				if (filterInfo.getFilterItems().size() > 0)
					filterInfo.mergeFilter(filter, "and");
				else
					filterInfo = filter;
			}
		} catch (Exception e) {
			handUIException(e);
		}
		return filterInfo;
	}

	protected void tblMain_tableClicked(KDTMouseEvent e) throws Exception {
		if (e.getClickCount() == 2) {
			int[] rowID = KDTableUtil.getSelectedRows(this.tblMain);
			if (this.isSingleSelect) {
				if (rowID.length > 0) {
					if (this.tblMain.getRow(rowID[0]) == null)
						return;
					String strID = this.tblMain.getRow(rowID[0]).getCell("id")
							.getValue().toString();
					this.selectPersonSet = new HashSet();
					this.selPersonUnitMap = new HashMap();
					this.selPersonPositionMap = new HashMap();
					this.selectPersonSet.add(strID);

					setReturnPositionAndUnit(strID, rowID[0]);

					btnConfirm_actionPerformed(null);
				}
			} else
				addDataToSelectTable(rowID);
		}
	}

	private void addDataToSelectTable(int[] rowID) throws Exception {
		String pId = null;
		for (int i = 0; i < rowID.length; i++) {
			if (this.tblMain.getRow(rowID[i]) == null)
				continue;
			pId = this.tblMain.getRow(rowID[i]).getCell("id").getValue()
					.toString();
			if (this.selectPersonSet.contains(pId)) {
				continue;
			}

			IRow curRow = this.tblSelectPerson.addRow();
			curRow.getCell("id").setValue(pId);
			curRow.getCell("number").setValue(
					this.tblMain.getRow(rowID[i]).getCell("number").getValue());
			curRow.getCell("name").setValue(
					this.tblMain.getRow(rowID[i]).getCell("name").getValue());
			curRow.getCell("position").setValue(
					this.tblMain.getRow(rowID[i]).getCell("position")
							.getValue());
			curRow.getCell("positionId").setValue(
					this.tblMain.getRow(rowID[i]).getCell("positionId")
							.getValue());

			curRow.getCell("adminUnitId").setValue(
					this.tblMain.getRow(rowID[i]).getCell("adminUnitId")
							.getValue());
			curRow.getCell("adminUnit").setValue(
					this.tblMain.getRow(rowID[i]).getCell("adminUnit")
							.getValue());

			curRow.getCell("adminDisName").setValue(
					this.tblMain.getRow(rowID[i]).getCell("adminDisName")
							.getValue());
			curRow.getCell("costCenter").setValue(
					this.tblMain.getRow(rowID[i]).getCell("costCenter")
							.getValue());

			curRow.getCell("attendanceCode").setValue(
					this.tblMain.getRow(rowID[i]).getCell("attendanceCode")
							.getValue());
			this.selectPersonSet.add(pId);
			addPersonSelectPositionMap(rowID[i]);
			setReturnPositionAndUnit(pId, rowID[i]);
		}
	}

	private void addPersonSelectPositionMap(int row) {
		if ((this.tblMain.getRow(row).getCell("positionId").getValue() != null)
				&& (this.tblMain.getRow(row).getCell("adminUnitId").getValue() != null)) {
			PositionInfo positionInfo = new PositionInfo();
			positionInfo.setId(BOSUuid.read(this.tblMain.getRow(row).getCell(
					"positionId").getValue().toString()));
			positionInfo.setName((String) this.tblMain.getRow(row).getCell(
					"position").getValue());
			AdminOrgUnitInfo adminInfo = new AdminOrgUnitInfo();
			adminInfo.setId(BOSUuid.read(this.tblMain.getRow(row).getCell(
					"adminUnitId").getValue().toString()));
			adminInfo.setName((String) this.tblMain.getRow(row).getCell(
					"adminUnit").getValue());
			adminInfo.setDisplayName((String) this.tblMain.getRow(row).getCell(
					"adminDisName").getValue());
			positionInfo.setAdminOrgUnit(adminInfo);
			String pId = this.tblMain.getRow(row).getCell("id").getValue()
					.toString();
			this.selectPersonPositionMap.put(pId, positionInfo);
		}
	}

	private void delDataFromSelectTable(int[] rowID) {
		String pId = null;
		for (int i = rowID.length - 1; i >= 0; i--) {
			if (rowID[i] < 0)
				continue;
			pId = this.tblSelectPerson.getRow(rowID[i]).getCell("id")
					.getValue().toString();
			this.tblSelectPerson.removeRow(rowID[i]);
			this.selectPersonSet.remove(pId);
			this.selectPersonPositionMap.remove(pId);
			this.selPersonPositionMap.remove(pId);
			this.selPersonUnitMap.remove(pId);
		}
	}

	protected CommonQueryDialog initCommonQueryDialog() {
		CommonQueryDialog dialog = super.initCommonQueryDialog();
		if ((this.hroSet != null) && (this.hroSet.size() > 0)) {
			dialog.setPromptBoxFactory(new HRF7SingleChangePromptBoxFactory(
					this.hroSet));
		}
		return dialog;
	}

	protected void chkInclude_actionPerformed(ActionEvent e) throws Exception {
		super.chkInclude_actionPerformed(e);

		treeMain_valueChanged(null);
	}

	public void actionView_actionPerformed(ActionEvent e) throws Exception {
		btnConfirm_actionPerformed(null);
	}

	protected void doFieldPermission() {
	}

	protected void initKeyStroke() {
	}

	protected void btnMaxBothWin_actionPerformed(ActionEvent e)
			throws Exception {
		super.btnMaxBothWin_actionPerformed(e);

		Window dialog = ComponentUtil.getOwnerWindow(null);
		if (!this.isMaxSize) {
			this.btnMaxBothWin.setToolTipText(EASResource.getString(
					"com.kingdee.eas.hr.emp.EMPAutoGenerateResource",
					"215_EmployeeMutiF7UI"));
			this.winSize = dialog.getBounds();
			Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
			Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(
					dialog.getGraphicsConfiguration());
			Rectangle desktopBounds = new Rectangle(screenInsets.left,
					screenInsets.top, screenSize.width - screenInsets.left
							- screenInsets.right, screenSize.height
							- screenInsets.top - screenInsets.bottom);

			dialog.setBounds(0, 0, desktopBounds.width, desktopBounds.height);
		} else {
			this.btnMaxBothWin.setToolTipText(EASResource.getString(
					"com.kingdee.eas.hr.emp.EMPAutoGenerateResource",
					"216_EmployeeMutiF7UI"));
			dialog.setBounds(this.winSize);
		}
		this.isMaxSize = (!this.isMaxSize);
	}

	protected void chkShowVirtualOrg_itemStateChanged(ItemEvent e)
			throws Exception {
		initAdminTree();
	}

	private void initAction() throws Exception {
		this.isUpgrade = AffairUpgradeFacadeFactory.getRemoteInstance()
				.isUpgrade();
		Object obj = this.getUIContext().get("Owner");
		if (obj instanceof EmployeeMultiF7PromptBox) {
			EmployeeMultiF7PromptBox empF7 = (EmployeeMultiF7PromptBox) obj;
			if (empF7.getF7ParamFromUI() != null) {
				Map map = empF7.getF7ParamFromUI().getUI().getUIContext();
				Object action = map.get("PROBATION_HIRE");
				if (action != null) {
					this.isProbationHire = (Boolean) action;
				}

				action = map.get("PROBATION_REGIGN");
				if (action != null) {
					this.isProbationResign = (Boolean) action;
				}

				action = map.get("CONTRACT_REGIGN");
				if (action != null) {
					this.isContractResgin = (Boolean) action;
				}
			}
		}
	}
}